package com.isoft.demo.controller;

import com.isoft.demo.common.ResponseData;
import com.isoft.demo.entity.CustomerInfo;
import com.isoft.demo.entity.Vehicle;
import com.isoft.demo.service.VehicleService;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@CrossOrigin
public class VehicleController {
    @Resource
    private VehicleService vehicleService;

    @GetMapping("/addVeh")
    public ResponseData addVehicle(Vehicle vehicle){
        ResponseData rs = vehicleService.addVehicle(vehicle);
        return rs;
    }
    @GetMapping("/updateVeh")
    public ResponseData updateVehicle(Vehicle vehicle){
        ResponseData rs = vehicleService.updateVehicle(vehicle);
        return rs;
    }
    @GetMapping("/deleteVeh")
    public ResponseData deleteVehicle(@Param(value = "vid") int vid){
        ResponseData rs = vehicleService.deleteVehicle(vid);
        return rs;
    }
    @GetMapping( "/allVeh")
    public ResponseData findAllVehicle(){
        ResponseData rs = vehicleService.findAllVehicle();
        return rs;
    }
    @GetMapping("/byVid")
    public ResponseData findByVid(Integer vid){
        ResponseData rs = vehicleService.findByVid(vid);
        return rs;
    }

    @GetMapping("/findIdle")
    public ResponseData findIdle(){
        ResponseData rs = vehicleService.findIdle();
        return rs;
    }
}
